
<head th:fragment="headerCss">
    <meta charset="utf-8">
    <title>全国职业院校技能大赛-教师赛</title>
    <meta content="width=device-width, initial-scale=1.0" name=	"viewport">
    <meta name="keywords" content="" />
    <meta name="description"
          content="全国职业院校技能大赛-教师赛" />
    <link rel="stylesheet" href="/js/layui/css/layui.css" >
    <!-- Bootstrap CSS File -->
    <link href="/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/css/examination/common.css" >
    <link rel="shortcut icon" href="../../bitbug_favicon.ico">
    <style type="text/css">
        #butt {
            width: 150px;
            height: 58px;
            font-size: 30px;
            line-height: 58px;
            color: #440000;
            background: #dd8e4f;
            border: 1px solid #ff6600;
            text-align: center;
            cursor: default;
        }
        #box {
            overflow: hidden;
            width: 0;
            height: 0;
        }
        #test {
            width: 100%;
            height: 100%;
            border-style: none;
        }

        #layui-layer1 .layui-layer-btn{
            text-align: center;
        }

        #layui-layer1 .layui-layer-btn .layui-layer-btn0{
            background: #FF6A66;
            color: #fff;
            border: none;
            font-size: 14px;
        }

        #layui-layer1 .layui-layer-btn .layui-layer-btn1{
            background: white;
            border:1px solid #FF6A66;
            font-size: 14px;
        }

        .signin {
            background: url("../../img/loginbgs.png");
        }

        .infoBox {
            background: none;
        }
        .redlogo {
            width: 365px;
        }
    </style>
</head>
<body class="signin">
<div class="infoBox">
    <div class="info">
        <div class="redlogo">
            <img src="/img/loaintitles.png" style="height: 55px">
        </div>
        <div class="attributes">
            <h1 id="roomNumber"></h1>
            <h1 id="seatNumber"></h1>
            <h1 id="name" style="font-size: 30px"></h1>
        </div>
    </div>
</div>
<div class="main_content">
    <div class="window_box">
        <div class="loginIns resetLoginIn">
            <h1 id="eaxmName"></h1>
            <div id="time" class="mar10 tips"></div>

            <div class="start">
                <p>考试开始时间</p>
                <div class="solid"></div>
                <p>考试结束时间</p>
            </div>

            <div class="end">
                <p id="startTime"></p>
                <p id="endTime"></p>
            </div>
            <!--<p style="font-size: 16px">总分100分，第一大题为单选题，共60道，合计60分；第二大题为多选题，共40道，合计40分总分100分，-->
            <!--第一大题为单选题，共60道，合计60分；第二大题为多选题，共40道，合计40分,-->
            <!--第一大题为单选题，共60道，合计60分；第二大题为多选题，共40道，合计40分</p>-->

<!--            <div class="mar10 enter" style="font-size: 18px;font-weight: bold">-->
<!--                注：开考后<span id="times"></span>分钟不可进入考试-->
<!--            </div>-->
<!--            <div class="mar10" style="text-align: center;font-size: 15px;display: none">-->
<!--                <label class="greyhound" for="radio"><input id="radio" type="checkbox">我已同意<a target="_blank" id="look" style="color: #E60012;cursor: pointer" onclick="lookView()">考试须知</a></label>&nbsp;&nbsp;-->
<!--            </div>-->

            <div class="optimize">
<!--                <div class="btnColor">-->
<!--                    <div id="showtime"></div>-->
<!--                </div>-->

                <div class="btnColor">
                    <input class="btn btn-block not-allowed" id="sub"  readonly  onclick="login();" value="开始考试"/>
                </div>
            </div>
            <p id="loadingText" style="text-align: center;color: red;font-size: 15px;margin-top: 15px"></p>
        </div>
    </div>
</div>
<!--<div id="box">-->
    <!--<iframe src="/examination/exam" id="test"></iframe>-->
<!--</div>-->
<div id="lookView" style="display: none;padding: 20px">
    <p id="examNotes"></p>
</div>
<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4" th:src="@{/js/jquery.min.js?v='2.1.4'}"></script>
<script src="/js/plugins/layer/layer.min.js" th:src="@{/js/plugins/layer/layer.min.js}"></script>
<script type="text/javascript">

    document.oncontextmenu=new Function("event.returnValue=false");
    document.onselectstart=new Function("event.returnValue=false");

    //f12、f11禁用
    document.onkeydown = function (e) {
        var ev = window.event || e;
        var code = ev.keyCode || ev.which;
        if (123 || 122 ||  115) {
            if(ev.preventDefault) {
                ev.preventDefault();
            } else {
                ev.keyCode = 0;
                ev.returnValue = false;
            }
        }
    };

    function lookView() {
        layer.open({
            title: '考试须知',
            type: 1,
            area: ['1000px', '600px'],
            fixed: false, //不固定
            maxmin: true,
            content: $("#lookView"),
            end: function () {
            },
            success: function () {
            }
        });
    }
    //倒计时
    $(function () {
        if(window.localStorage){
            var intro = JSON.parse(window.localStorage.getItem("intro"));
            var info = JSON.parse(window.localStorage.getItem("info"));
            var times =JSON.parse(window.localStorage.getItem("times"));
            $('#times').text(intro.durations);
            var times1 = times * 60;

            $("#startTime").html(intro.startTimes);
            //监督员设置了延时
            if(info.endDate !=undefined){
                $("#endTime").html(info.endDate);
            }else{
               $("#endTime").html(intro.endTimes);
            }

            $("#time").html("考试时长："+intro.durations+"分钟");
            $("#examNotes").html(intro.examNotes);
            $("#name").html("二次加密："+info.num2);
            //$("#roomNumber").html("考场号："+info.roomNumber);
            //$("#seatNumber").html("座位号："+info.seatNumber);
        }else{
            layer.msg("请换浏览器，最佳为谷歌")
        }
        $.ajax({
            url: "/jzApi/examinations/selExaminationPaper",
            type:'POST',
            data:{id:JSON.parse(window.localStorage.getItem("intro")).id},
            success: function (r) {
                $("#eaxmName").html(intro.name);
                if(window.localStorage){
                    window.localStorage.setItem("exam",JSON.stringify(r.data));
                }else{
                    layer.msg("请换浏览器，最佳为谷歌")
                }
            }
        });

        $.ajax({
        	type: "POST",
            url: "/jzApi/examinations/getNowDateTime",
            data: {},
            success: function (r) {
               //console.log("map =" , r.data.endTime);
                window.localStorage.setItem("nowDate",r);
                countDown();
            }
        });
        function addZero(i) {
            return i < 10 ? "0" + i: i + "";
        }
        function countDown() {
            var nowTime = new Date(window.localStorage.getItem("nowDate").replace(/-/g,"/"));
            window.localStorage.setItem("nowDate",new Date(nowTime.getTime()+1000));
            var endTime = new Date(JSON.parse(window.localStorage.getItem("intro")).startTimes.replace(/-/g,"/"));  //考试开始时间
            var leftTime = parseInt((endTime.getTime() - nowTime.getTime()) / 1000);
            // var d = parseInt(lefTtime / (24*60*60))
            var h = parseInt(leftTime / (60 * 60) % 24);
            var m = parseInt(leftTime / 60 % 60);
            var s = parseInt(leftTime % 60);
            // d = addZero(d)
            h = addZero(h);
            m = addZero(m);
            s = addZero(s);
            // document.querySelector("#showtime").innerHTML = '考试倒计时 '+h+'时'+m+'分'+s+'秒';
            if (leftTime <= 0) {
                $("#sub").attr("disabled",false);
            //     // if(leftTime <= -times1&&JSON.parse(window.localStorage.getItem("info")).state!=8){  //离开考时间超过30分钟未进入过考试的，禁止考试
            //         // $("#sub").attr("disabled",true);
            //         // $("#showtime").hide();
            //         // $("#sub").addClass("not-allowed");
            //         // $("#sub").val("考试已禁止进入");
            //     // }else{  //倒计时为0，考试开始
            //         document.querySelector("#showtime").innerHTML = "考试已开始";
            //         $("#sub").attr("disabled",false);
            //         $("#sub").removeClass("not-allowed");
            //         layer.confirm("已到考试时间，是否进入考试？", {
            //             btn: ['确定', '取消']
            //         }, function (index, layero) {
            //             login()
            //         }, function (index) {
            //         });
            //         return;
            //     // }
            }else {
                $("#sub").attr("disabled",true);
                $('#loadingText').text('未到开始时间，无法进入考试!')
            }
            setTimeout(countDown, 1000);
        }
    });
    function login() {
        // if (!$('#radio').prop("checked")) {
        //     layer.msg("请勾选已同意");
        //     return false
        // }
        // window.open('/examination/exam', '考试', 'left=0,top=0,width='+ (screen.availWidth - 10) +',height='+ (screen.availHeight-50) +',menubar=no,fullscreen=yes,location=no' )
        $.ajax({
            url: "/jzApi/examinations/changeState",
            type:'POST',
            data:{id:JSON.parse(window.localStorage.getItem("info")).stuSignId},
            success: function (r) {
                if(r) 
                {
                    location.href='/examination/caseExamPPT';
                }else{
                    alert("未知错误，请重新登录！");
                }
            }
        });
        
    }

</script>

</body>





